package fellipe.exemplo.twittertes;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class Tela2Activity extends Activity {
	
	private EditText editText;
	private Button botaoOk;
	private Button botaoCancelar;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.tela2);
		
		botaoOk = (Button) findViewById(R.id.bnt_Ok);
		botaoCancelar = (Button) findViewById(R.id.bnt_cancelar);
		
		botaoCancelar.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				setResult(RESULT_CANCELED);
				finish();
			}
		});
		
		botaoOk.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				editText = (EditText) findViewById(R.id.texto);
				String texto = editText.getText().toString();
				
				Intent i = new Intent();
				i.putExtra("mensagem", texto);
				
				setResult(RESULT_OK, i);
				finish();
			}
		});
		
	}
}
